#pragma once
#include <string>
#include <math.h>
#include "Constant.h"
#include "vector3.h"
#include "Types.h"
#include "base.h"
using namespace std;

string GetWorkingDir();
bool glErrorCheck();
#define glTranslateV(vfT) glTranslatef(vfT.x, vfT.y, vfT.z)
#define glRotateV(vfR) glRotatef(vfR.x, -1.0f, 0.0f, 0.0f);glRotatef(vfR.y, 0.0f, -1.0f, 0.0f);glRotatef(vfR.z, 0.0f, 0.0f, -1.0f)
#define glTexCoordV(vPoint) glTexCoord2f(vPoint.x, vPoint.y)
#define glVertexV(vPoint) glVertex3f(vPoint.x, vPoint.y, vPoint.z)
#define glColorV(c) glColor4ub(c.r, c.g, c.b, c.a)
inline float glSin(float degrees)
{
	return (float)sin((double)(degrees * DEG_TO_RAD));
}
inline float glCos(float degrees)
{
	return (float)cos((double)(degrees * DEG_TO_RAD));
}
inline float clampf(float value, float min, float max)
{
	if(value > max)
		return max;
	if(value < min)
		return min;
	return value;
}
inline int clamp(int value, int min, int max)
{
	if(value > max)
		return max;
	if(value < min)
		return min;
	return value;
}
inline void glClearColor(const color &c)
{
	glClearColor(c.fR(), c.fG(), c.fB(), c.fA());
}
inline int NextPowerof(int x, int of = 2)
{
	double logbase2 = (double)log((double)x) / (double)log((double)2);
	return (int)(pow(2,ceil(logbase2)));
}
/*
	Linear Interpolation function
*/
inline float lerp(float x0, float x1, float step)
{
	return x0 + (x1-x0)*step;
}
/*
	Cosine Interpolation function
*/
inline float cerp(float x0, float x1, float step)
{
	float stepCos = cosf(step * PI);
	return x0 + (x1-x0)*stepCos;
}

wstring MakeUnicodeString(const string &src);